package com.kogi.androidpatt.gettingInput.enterValue;

import com.kogi.patterns.R;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;

public class Slider extends Activity implements SeekBar.OnSeekBarChangeListener 

{
	SeekBar redBar,greenBar,blueBar;
	TextView redBarTag,greenBarTag,blueBarTag;
    TextView redProgressText,greenProgressText,blueProgressText;
    TextView redTrackingText,greenTrackingText,BlueTrakingText;
    TextView colorBox,valueHex;
    int red = 255;
    int green = 255;
    int blue = 255;
    
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
        setContentView(R.layout.getting_input_slider);
        redBarTag = (TextView)findViewById(R.id.tagRedBar);
        redBarTag.setText("Red");
        redBar = (SeekBar)findViewById(R.id.redBar);
        redBar.setOnSeekBarChangeListener(this);        
        redProgressText = (TextView)findViewById(R.id.redProgress);
        redProgressText.setText("Value = 3");
        greenBar = (SeekBar)findViewById(R.id.greenBar);
        greenBar.setOnSeekBarChangeListener(this);
        greenBarTag = (TextView)findViewById(R.id.tagGreenBar);
        greenBarTag.setText("Green");
        greenProgressText = (TextView)findViewById(R.id.greenProgress); 
        greenProgressText.setText("Value = 3");
        blueBar = (SeekBar)findViewById(R.id.blueBar);
        blueBar.setOnSeekBarChangeListener(this);
        blueBarTag = (TextView)findViewById(R.id.tagBlueBar);
        blueBarTag.setText("Blue");
        blueProgressText = (TextView)findViewById(R.id.blueProgress); 
        blueProgressText.setText("Value = 3");  
        colorBox = (TextView)findViewById(R.id.colorBox);
        valueHex = (TextView)findViewById(R.id.hexaValue);
        valueHex.setText("Color = 0xFFFFFFFF");
	}
	
	public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) 
	{
		if(seekBar == this.redBar)
		{	
			red = progress;
			redProgressText.setText("Value = "+progress);			
		}	
		else if (seekBar == this.greenBar)
		{	
			green = progress;
			greenProgressText.setText("Value = "+progress);
		}	
		else
		{	
			blue = progress;
			blueProgressText.setText("Value = "+progress);
		}	
		colorBox.setBackgroundColor(Color.rgb(red, green, blue));
		valueHex.setText("Color = 0x"+Integer.toHexString(Color.rgb(red, green, blue)).toUpperCase());
    }

    public void onStopTrackingTouch(SeekBar seekBar) 
    {
       
    }

	@Override
	public void onStartTrackingTouch(SeekBar arg0) 
	{
		// TODO Auto-generated method stub
		
	}

}
